using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using XLua;

public class App : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        //初始化解释器
        LuaMgr.GetInstance().Init();
        LuaMgr.GetInstance().DoLuaFile("Main");
        LuaMgr.GetInstance().Global.Get<UnityAction>("Start")();
    }

    // Update is called once per frame
    void Update()
    {
        // UnityAction update = LuaMgr.GetInstance().Global.Get<UnityAction>("Update");
        // update();
        
        LuaMgr.GetInstance().Global.Get<UnityAction>("Update2")();

        // if (Input.GetMouseButtonDown(0))
        // {
        //     var targetPos = GetTargetPos();
        //     Debug.Log("点击位置：" + targetPos);
        // }
        // PlayerMove_FollowMouse();
        
    }
    
    [LuaCallCSharp]
    public Vector3 GetTargetPos() { // 获取目标位置
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo = new RaycastHit();
        Physics.Raycast(ray, out hitInfo);
        return hitInfo.point;
    }
}